﻿//using System;
//using System.Collections.Generic;
//using System.Collections.ObjectModel;
//using Birkelund.QueryStrings.Interfaces;
//using Birkelund.QueryStrings.Tokens;
//using Birkelund.QueryStrings.Internals;

//namespace Birkelund.QueryStrings
//{
//    /// <summary>
//    /// Class to enable support for writing "mailto:"
//    /// </summary>
//    public class MailUrlGenerator : IUriGenerator
//    {
//        /// <summary>
//        /// Gets or sets to.
//        /// </summary>
//        /// <value>To.</value>
//        public string To { get; private set; }

//        /// <summary>
//        /// Gets or sets the cc.
//        /// </summary>
//        /// <value>The cc.</value>
//        public ICollection<string> Cc { get; private set; }

//        /// <summary>
//        /// Gets or sets the BCC.
//        /// </summary>
//        /// <value>The BCC.</value>
//        public ICollection<string> Bcc { get; private set; }

//        /// <summary>
//        /// Gets or sets the body.
//        /// </summary>
//        /// <value>The body.</value>
//        public string Body { get; set; }

//        /// <summary>
//        /// Gets or sets the subject.
//        /// </summary>
//        /// <value>The subject.</value>
//        public string Subject { get; set; }

//        /// <summary>
//        /// Initializes a new instance of the <see cref="MailUrlGenerator"/> class.
//        /// </summary>
//        /// <param name="to">To.</param>
//        public MailUrlGenerator(string to)
//        {
//            ArgumentValidation.ThrowIfNull(to, "to");

//            To = to;
//            Cc = new Collection<string>();
//            Bcc = new Collection<string>();
//        }

//        /// <summary>
//        /// Generates the query as string.
//        /// </summary>
//        /// <returns></returns>
//        public string GenerateQueryAsString()
//        {
//            //don't render any of the tokens if no value is provided (RenderIfEmptyValue = false)
//            StringsToken cc = new StringsToken("cc") { RenderIfEmptyValue = false };
//            StringsToken bcc = new StringsToken("bcc") { RenderIfEmptyValue = false };
//            StringToken subject = new StringToken("subject") { RenderIfEmptyValue = false };
//            StringToken body = new StringToken("body") { RenderIfEmptyValue = false };

//            UriWriter writer = UriWriter.CreateFromUri(new Uri(@"mailto:"));
//            //writer.SetPath(To);
//            writer.SortTokens = false; //let the order be fixed instead of alphabetic
//            writer.SetToken(cc, Cc);
//            writer.SetToken(bcc, Bcc);
//            writer.SetToken(subject, Subject);
//            writer.SetToken(body, Body);

//            return writer.GenerateQueryAsString().Replace("+", "%20"); // a small hack
//        }

//        /// <summary>
//        /// Generates the query as URI.
//        /// </summary>
//        /// <returns></returns>
//        public Uri GenerateQueryAsUri()
//        {
//            string url = GenerateQueryAsString();
//            return new Uri(url);
//        }
//    }
//}

